//package org.activoricordi.app.snippet
package edu.ucdavis.fiehnlab.alchemy.alchemyAdmin.snippet



/**
 * Created with IntelliJ IDEA.
 * User: naru
 * Date: 3/28/13
 * Time: 10:05 AM
 * To change this template use File | Settings | File Templates.
 */

import _root_.scala.xml.{NodeSeq, Text}
import _root_.net.liftweb.util._
import _root_.net.liftweb.common._
import _root_.java.util.Date
import  edu.ucdavis.fiehnlab.alchemy.alchemyAdmin.lib._
import Helpers._
import net.liftweb._
import http._
import common._
import util.Helpers._
import net.liftweb.http.SHtml._


class InputMethod {

  def add (xhtml:NodeSeq): NodeSeq ={
    /**
     * initialize all variable to default values
     */
    var name = ""
    var riWindow = "0"
    var massWindow = "0"
    var description = ""
    /**
     * function to check negative values
     */
    def addMethod() =
      if (riWindow.toDouble <=0) {
        S.error("Invalid value")
      }else {
        S.redirectTo("/addCompound")
      }

    /**
     * bind all Method properties to forum html
     */
    bind("entry",xhtml,
          "name" -> SHtml.text(name, name = _),
          "riWindow" -> SHtml.text(riWindow,riWindow = _),
          "massWindow"-> SHtml.text(massWindow,massWindow = _),
          "description" ->SHtml.textarea(description, description = _,"cols" -> "20", "rows" -> "20"),
          "submit" -> SHtml.submit("Add Method", addMethod)
        )

  }

}

